﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace AB_SD_MockProject
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // if there are cookies in client browser
            if (Request.Cookies["CurrentUser"] != null)
            {
                // store sessions by cookies value
                Session["CurrentUser"] = Request.Cookies["CurrentUser"].Value.ToString();
                if (Request.Cookies["IsSuper"] != null)
                {
                    if (Boolean.Parse(Request.Cookies["IsSuper"].Value))
                    {
                        Session["IsSuper"] = Boolean.TrueString;                        
                    }
                }
                Session["IsAdmin"] = Boolean.FalseString;                
            }

            // if user is not logged in
            // redirect to login page
            if (Session["CurrentUser"] == null)
                Response.Redirect("Login.aspx");
        }
    }
}
